<!DOCTYPE html>
<html>
<head>
<title>maximun char</title>
<meta name="keywords" charset=utf-8/>
<!--[if !IE]> -->
  <script src="http://cdn.bootcss.com/jquery/2.2.0/jquery.min.js"></script>
  <!-- <![endif]-->
  <!--[if IE]>
      <script src="http://cdn.bootcss.com/jquery/1.12.0/jquery.js"></script>
  <![endif]-->
<style>
*{
  margin:0;
  padding:0;
}

</style>
</head>
<body>
  <div>hello js</div>

<script>
var str = 'asdfssaaasasasasaa';
var res = maximunChar(str);
console.log(res);
alert('出现次数最多的是:'+res['iIndex']+'出现'+res['iMax']+'次');
function maximunChar(Str){
	var json = {};
	  	for (var i = 0; i < str.length; i++) {
          	if(!json[str.charAt(i)]){
                json[str.charAt(i)] = 1;
          	}else{
                json[str.charAt(i)]++;
          	}
	  	}
	  	console.log(json);
	var results={};
  	var iMax = 0;
  	var iIndex = '';
  	for(var i in json){
        if(json[i]>iMax){
            iMax = json[i];
            iIndex = i;
        }
  	}
  	results['iMax'] = iMax;
    results['iIndex'] = iIndex;
  	return results;
}
 
</script>
</body>
</html>